home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6100 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  71 lines

  1. Path: ix.netcom.com!netnews
  2. From: jeremyx@ix.netcom.com(Jeremy Johnston )
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: U MUST READ THIS!!!!!
  5. Date: 11 Feb 1996 18:47:48 GMT
  6. Organization: Netcom
  7. Message-ID: <4fldkk$k3h@ixnews5.ix.netcom.com>
  8. References: <4epbn1$4hq@ixnews7.ix.netcom.com> <4fl0l2$pl1@news1.delphi.com>
  9. NNTP-Posting-Host: hun-al1-03.ix.netcom.com
  10. X-NETCOM-Date: Sun Feb 11 10:47:48 AM PST 1996
  11.  
  12. In <4fl0l2$pl1@news1.delphi.com> JGUILLORY@delphi.com writes: 
  13. >
  14. >
  15. >Quoting jeremyx from a message in comp.lang.c++
  16. > je> Everyone keeps telling me not to use the "goto"
  17. > je> statement,they act like it's the plague! What is wrong with the
  18. goto
  19. > je> statement & what can i use in it's place?
  20. >
  21. >Proper structured code needs no GOTO's eg: Consider the following:
  22. >(untested)
  23. >
  24. >#include <stdio.h>
  25. >
  26. >void main(void) {
  27. >FILE *f;
  28. >label E1;
  29. >char  command[]="DIR/W";
  30. >
  31. >        f = fopen("TEST.BAT","wt");
  32. >        if (f==NULL) goto E1;
  33. >        fprintf(f,"%s\n",command);
  34. >        fclose(f);
  35. >E1:
  36. >}
  37. >
  38. >-- My syntax on the goto / Labels may be off, as I haven't used goto's
  39. >   in C/C++ much.... (never needed them....)
  40. >
  41. >The above could be simply re-written as:
  42. >
  43. >#include <stdio.h>
  44. >
  45. >void main(void) {
  46. >FILE *f;
  47. >char command[]="DIR/W";
  48. >
  49. >        f = fopen("TEST.BAT","wt");
  50. >        if (f!=NULL) {
  51. >          fprintf(f,"%s\n",command);
  52. >          fclose(f);
  53. >        }
  54. >}
  55. >
  56. >Without GOTO's, you have 1 Start, and 1 Stop, and can write a
  57. flow-chart
  58. >to match it very easily, with GOTO's you have 1 start, many stop's,
  59. >and a big headache to look at it....
  60. >
  61. >John H. Guillory
  62. >JGuillory@Delphi.Com
  63. >
  64. >Rainbow V 1.17.0 for Delphi - Test Drive
  65. >
  66.  
  67.  WHOA!!!!!!!!!   THat looked like alien writing! what did that program
  68. do?! i know it open a file but what was all that other stuff?! This is
  69. the most complicated language i know ( i thought latin was hard! )
  70. BASIC is much easier>
  71.